package top.healthylife.gateway.platform.lexin.dto.lexinzhixininfostandard.res;

import cn.hutool.core.util.ObjectUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @author : GaoZeXi
 * @date 2021/11/2 18:05
 */
@Data
@Accessors(chain = true)
@ApiModel("致信分标准版")
public class ZhiXinInfo {
    @ApiModelProperty(value = "致信分", notes = "分数 [300,900]	基于关联数据， 通过知识图谱、 置信模型等技术，识别资料伪 造风险的评分")
    private String confidenceScore;
    @ApiModelProperty(value = "身份证号vs姓名", notes = "直输	[1,2,3,4]	身份证号与姓名的置信度等级")
    private String cfdsIdAndName;
    @ApiModelProperty(value = "工作单位vs工作地址", notes = "直输	[1,2,3,4]	工作单位与工作地址的置信度等级")
    private String cfdsCompanyAndWorkAddr;
    @ApiModelProperty(value = "手机号vs身份证号", notes = "直输	[1,2,3,4]	手机号与身份证号的置信度等级")
    private String cfdsMobileAndId;
    @ApiModelProperty(value = "手机号vs住址", notes = "直输	[1,2,3,4]	手机号与家庭地址的置信度等级")
    private String cfdsMobileAndHomeAddr;
    @ApiModelProperty(value = "手机号vs住址距离", notes = "直输	距离值： 大于等于 0	手机号与家庭地址的距离")
    private String gapMobileAndHomeAddr;
    @ApiModelProperty(value = "手机号vs工作地址", notes = "直输	[1,2,3,4]	手机号与工作地址的置信度等级")
    private String cfdsMobileAndWorkAddr;
    @ApiModelProperty(value = "手机号vs工作地址距离", notes = "直输	距离值： 大于等于 0	手机号与工作地址的距离")
    private String gapMobileAndWorkAddr;
    @ApiModelProperty(value = "手机号vsIMEI", notes = "直输	[1,2,3,4]	手机号与设备 IMEI 号的置信度等级")
    private String cfdsMobileAndImei;
    @ApiModelProperty(value = "手机号vsIDFA", notes = "直输	[1,2,3,4]	手机号与设备 IDFA 号的置信度等级")
    private String cfdsMobileAndIdfa;
    @ApiModelProperty(value = "180D内手机号码活跃度", notes = "直输	[1,2,3,4]	根据用户的移动数据评估 180天内手机号码的活跃情况等级")
    private String mobileAct180d;
    @ApiModelProperty(value = "180D内IMEI活跃度", notes = "直输 [1,2,3,4]	根据用户的移动数据评估 180 天内设备 IMEI 号的活跃情况等级")
    private String imeiAct180d;
    @ApiModelProperty(value = "180D内IDFA活跃度", notes = "直输 [1,2,3,4]	根据用户的移动数据评估 180 天内设备 IDFA 号的活跃情况等级")
    private String idfaAct180d;
    @ApiModelProperty(value = "致信分-反解析京东分", notes = "")
    private String tencentFieldUniformityScore;

//    public static void main(String[] args) {
//        ZhiXinInfo zhiXinInfo = new ZhiXinInfo().setConfidenceScore("870");
//        System.out.println("tencentFieldUniformityScore = " + zhiXinInfo.getTencentFieldUniformityScore());
//    }

    public String getTencentFieldUniformityScore(){
        int minOri = 300;
        int maxOri = 900;
        int minNew = 0;
        int maxNew = 100;
        int diffMaxMinOri =maxOri-minOri;
        int diffMaxMinNew =maxNew-minNew;
        float v;
        try {
            v = Float.parseFloat(this.confidenceScore);
        }catch (Exception e){
            return "-1";
        }
        if(ObjectUtil.isNull(v)||v<0){
            return "-1";
        }else{
            float xNew = minNew+((v-minOri)/diffMaxMinOri)*diffMaxMinNew;
            if(xNew<minNew||xNew>maxNew){
                return "-1";
            }
            return String.valueOf((int)xNew);
        }
    }
}
